<?php
class Subcategorymanager_Model_Updatesubcategorydata implements Subcategorymanager_Model_Mainable{
    
    private $core_controller_notnull;
    private $core_controller_tokencheckout;
    
    private $subcategorymanager_data_updatesubcategorysettings;
    private $subcategorymanager_data_updatesubcategorymetavalues;
    private $subcategorymanager_data_updatesubcategorycontentvalues;
    
    private $excepted_result = 1;
    
    private $update_subcategory_settings_result;
    private $update_subcategory_meta_values_result;
    private $udpate_subcategory_content_values_result;
    
    public function main(array $variables = null) {
        $this->core_controller_notnull = new Core_Controller_Notnull;
        $this->core_controller_notnull->main($variables);
        $this->core_controller_tokencheckout = new Core_Controller_Tokencheckout;
        $this->core_controller_tokencheckout->main($variables['post']);
        
        $this->subcategorymanager_data_updatesubcategorysettings = new Subcategorymanager_Data_Updatesubcategorysettings;
        $this->subcategorymanager_data_updatesubcategorymetavalues = new Subcategorymanager_Data_Updatesubcategorymetavalues;
        $this->subcategorymanager_data_updatesubcategorycontentvalues = new Subcategorymanager_Data_Updatesubcategorycontentvalues;
        
        $this->update_subcategory_settings_result = $this->subcategorymanager_data_updatesubcategorysettings->main($variables);
        $this->update_subcategory_meta_values_result = $this->subcategorymanager_data_updatesubcategorymetavalues->main($variables);
        $this->udpate_subcategory_content_values_result = $this->subcategorymanager_data_updatesubcategorycontentvalues->main($variables);
        
        if(
                ($this->update_subcategory_settings_result == $this->excepted_result) &&
                ($this->update_subcategory_meta_values_result == $this->excepted_result) &&
                ($this->udpate_subcategory_content_values_result == $this->excepted_result)
                ){
            header("Location: ".SITE_ROOT."zarzadzaj-podkategoriami.html");
        }
        else {
            header("Location: ".SITE_ROOT."zarzadzaj-podkategoriami.html");
        }
    }

}
